<?php
class IndexController extends Sosweb_Controller_Action
{
	function init()
	{
		parent::init();
		$this->logger->info('Inicjalizacja strony domowej sosweb.pl przez użytkownika z IP: '.$_SERVER['REMOTE_ADDR']);
	}

	function indexAction()
	{
        $request = clone $this->getRequest();
        $request->setActionName('about');
        $this->_helper->actionStack($request);

        $request = clone $this->getRequest();
        $request->setActionName('welcome');
        $this->_helper->actionStack($request);
        
        $request = clone $this->getRequest();
        $request->setActionName('projects');
        $this->_helper->actionStack($request);        
	}
	
	function aboutAction()
	{
	    $this->view->getHelper('HeadLink')->appendStylesheet($this->view->baseUrl.'/public/styles/index.about.css');
	}
	
	function welcomeAction()
	{
	    $this->view->getHelper('HeadLink')->appendStylesheet($this->view->baseUrl.'/public/styles/index.welcome.css');
	}	
	
	function projectsAction()
	{
	    $this->view->getHelper('HeadLink')->appendStylesheet($this->view->baseUrl.'/public/styles/index.projects.css');
	    
	    $pt_table = new PortfolioThumbs();
	    $select = $pt_table->select();
		$select->setIntegrityCheck(false)
				->from($pt_table, array('id', 'name'))
				->joinInner('web_portfolio_preview', 'web_portfolio_projects.id=web_portfolio_preview.id', array('link', 'href', 'thumb', 'tooltip'))
       			->where('web_portfolio_preview.is_main = ?', '1')
       			->order('web_portfolio_projects.valid_from DESC');
		
       	try
       	{
       		$this->logger->info('Fetching projects link thumbnails. '.$select->assemble());
			$rows = $pt_table->fetchAll($select);
       	}
		catch(Zend_Exception $ex)
		{
			$this->logger->error($ex->getMessage());
		}
		
	    $this->view->projects = $rows;
	}		
}
